package ai

import (
	"fmt"
	"strconv"

	http_label_center "gobase/http_work_flow/label_center"
	ocrx "gobase/http_work_flow/label_center/ai/ocr"
)

// 数据转绘制
func Data2OCRHp(value *ocrx.RespHp) (_frame http_label_center.Tag, _err error) {
	var metas = make([]http_label_center.Meta, 0)
	if len(value.Items) == 0 {
		_err = fmt.Errorf("没有搜索文字 %+v", value)
		return
	}
	for _, v := range value.Items {
		var meta = http_label_center.Meta{
			X:      int64(v.ItemCoord.X),
			Y:      int64(v.ItemCoord.Y),
			Remark: "OCR高精度文字识别",
			TypeId: http_label_center.IdSchemeOCR高精度文字识别,
			// ProtoWidth:  1920,
			// ProtoHeight: 1080,
			Rect: &http_label_center.Rect{
				Width:  int64(v.ItemCoord.Width),
				Height: int64(v.ItemCoord.Height),
				Text:   v.ItemString,
				Center: false,
			},
		}
		meta.Rect.Text = v.ItemString
		metas = append(metas, meta)
	}
	timeStampMs, _err := strconv.ParseInt(value.SessionId, 10, 64)
	_frame = http_label_center.Tag{
		Metas: metas,
		AbsoluteTime: &http_label_center.AbsoluteTime{
			CenterUnixMs: timeStampMs,
			DurationMs:   2000,
		},
	}
	return
}
